############
# Figures ALL
############
library(MASS)
library(Zelig)
library(MNP)


#################
# MNP Tables
#################

rm(list=ls())
setwd("C:/WTO_Midwest/")

WTOdata <- read.csv(file="WTO_MNP_2013_03_04.csv",head=TRUE,sep=",")
attach(WTOdata)
#names(WTOdata)

WTOdata$PlEP_UE<-WTOdata$Plaintiff_UE*WTOdata$Elec_Prox_Plaintiff
WTOdata$TPOimp_PEP<-WTOdata$TPO_imp*WTOdata$Pres_Elec_Prox

### Model 5: Base
m5 <- mnp(fstatus2 ~ PE1_UE + Unemp_6mo + PE1 + Exports_6mo + Imports_6mo,
	coef.start = matrix(0, ncol=12, nrow=1), p.var = 100,
	cov.start = matrix(0.9, ncol=2, nrow=2) + diag(0.1, 2),
	data = WTOdata, n.draws = 70000, burnin = 20000, verbose = TRUE, thin = 3)
summary(m5)

### Model 6: Base + Plaintiff
m6 <- mnp(fstatus2 ~ PE1_UE + Unemp_6mo + PE1 + Exports_6mo + Imports_6mo + Plaintiff_PCGDP + PlEP1_PlUE + Plaintiff_UE + PlE1,
	coef.start = matrix(0, ncol=20, nrow=1), p.var = 80,
	cov.start = matrix(0.9, ncol=2, nrow=2) + diag(0.1, 2),
	data = WTOdata, n.draws = 60000, burnin = 15000, verbose = TRUE, thin = 3)
summary(m6)

### Model 7: Base + Age, Age^2, Month, Month^2
m7 <- mnp(fstatus2 ~ PE1_UE + Unemp_6mo + PE1 + Exports_6mo + Imports_6mo + Age + Age2 + Month + Month2,
	coef.start = matrix(0, ncol=20, nrow=1), p.var = 100,
	cov.start = matrix(0.9, ncol=2, nrow=2) + diag(0.1, 2),
	data = WTOdata, n.draws = 70000, burnin = 20000, verbose = TRUE, thin = 3)
summary(m7)

### Model 8: Base + Plaintiff + Age, Age^2, Month, Month^2
m8 <- mnp(fstatus2 ~ PE1_UE + Unemp_6mo + PE1 + Exports_6mo + Imports_6mo + Plaintiff_PCGDP + PlEP1_PlUE + Plaintiff_UE + PlE1 + Age + Age2 + Month + Month2,
	coef.start = matrix(0, ncol=28, nrow=1), p.var = 80,
	cov.start = matrix(0.9, ncol=2, nrow=2) + diag(0.1, 2),
	data = WTOdata, n.draws = 60000, burnin = 15000, verbose = TRUE, thin = 3)
summary(m8)
